package com.lesson23.controller;

import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lesson23.utils.AesUtils;

@RestController
public class RevEncryptDataController {

	@RequestMapping(value={"/rev/encryptData"})
	public Map<String, Object> encryptData(String data){
		Map<String, Object> results = new HashMap<String, Object>();
		 results.put("code", "000000");
		 results.put("msg", "success");
		 System.out.println("data = "+ data);
		 return results;
	}

	
	@RequestMapping(value={"/rev/decryptResp"})
	public String decryptResp(String data){
		 System.out.println("data = "+ data);
		 byte[] b = AesUtils.ecrypt(data, "hq0BL7XCPDtno6lykvO6kw==");
		 return Base64.getEncoder().encodeToString(b);
	}
	
}
